{include file="admin@public/header" /}
<link rel="stylesheet" href="/public/static/admin/css/report.css" />
<link rel="stylesheet" href="/public/static/admin/easyui/layui-v2.6.8/css/layui.css">


<link href="/public/static/admin/blue/bills.css?ver=20210803202401" rel="stylesheet" type="text/css">
<style>
  .wrapper {
    padding: 0;
  }

  .mod-search {
    padding: 5px 0 5px 16px;
  }

  .gridArea {
    padding: 7px 14px 0 16px;
  }

  .gridArea .btns {
    padding: 0 0 7px 0;
  }

  .ui-jqgrid-bdiv tr.ui-state-highlight {
    background: #f8ff94
  }

  .con-footer ul li label.wt55 {
    /* width: 55px; */
    width: auto;
  }

  #billTitle.wt190 {
    width: 320px;
  }

  .con-footer ul.maxwt-none {
    max-width: none;
  }

  .ui-jqgrid a.xhtRed {
    color: red;
  }

  .ui-jqgrid a.xhtRed:hover {
    color: red;
  }

  .con-footer .ctn-wrap {
    display: inline;
    padding: 0 6px 0 5px;
  }

  .con-footer ul li {
    min-width: 185px;
  }

  #billNo {
    width: 293px;
  }

  .layui-form-checkbox[lay-skin=primary]:hover i {
    border-color: #5dc5e7;
  }

  .layui-form-checked[lay-skin=primary] i {
    background-color: #5dc5e7;
  }

  .layui-form-radio {
    line-height: 30px;
  }

  .layui-form-radio *,
  .layui-form-checkbox span {
    font-size: 12px;
  }

  .con-footer ul li label {
    width: 66px;
  }

  .layui-form-radio {
    margin: 0;
  }

  .layui-form-radio>i:hover,
  .layui-form-radioed>i {
    border-color: #5dc5e7;
  }

  .layui-form-radio>i:hover,
  .layui-form-radioed>i {
    color: #5dc5e7;
  }

  .layui-form-checkbox[lay-skin=primary] i {
    padding: 0;
  }

  #filterItems {
    margin-right: 0;
  }
</style>
</head>


<div class="wrapper">

  <!-- header -->
  <div class="mod-search cf" id="report-search">
    <div class="l" id="filter-menu">
      <ul class="ul-inline fix layui-form" id="filterItems" style="height: auto;font-size: 12px;">
        <li id="date" style="display: list-item;">
          <label>开票日期:</label>
          <input type="date" value="" class="ui-input " name="filter-billFromDate" id="filter-billFromDate" maxlength="10" style="width: 120px;">
          <span class="todate"> 至 </span>
          <input type="date" value="" class="ui-input " name="filter-billFromDate" id="filter-billToDate" maxlength="10" style="width: 120px;">
        </li>
        <li id="date" style="display: list-item;">
          <label>单据日期:</label>
          <input type="date" value="" class="ui-input " name="filter-fromDate" id="filter-fromDate" maxlength="10"
            style="width: 120px;">
          <span class="todate"> 至 </span>
          <input type="date" value="" class="ui-input " name="filter-toDate" id="filter-toDate" maxlength="10"
            style="width: 120px;">
        </li>
        <li id="billsNo" style="display: list-item;">
          <label>单据编号:</label>
          <input type="text" class="ui-input ui-input-ph" id="billsNoAuto">
        </li>

        <!-- 选择客户 -->
				{include file="admin@select/customer"/}

        <li id="bill_no" style="display: list-item;">
          <label>发票号:</label>
          <input type="text" class="ui-input ui-input-ph" id="billNoAuto">
        </li>
        <li id="bill_title" style="display: list-item;">
          <label>发票抬头:</label>
          <input type="text" class="ui-input ui-input-ph" id="billTitleAuto">
          <div class="btns" style="top: -2px;float: right;position: relative;margin-top: 0;margin-left: 10px;"><a
              class="ui-btn mrb ui-btn-search" id="filter-submit">查询</a></div>
        </li>
      </ul>
    </div>
  </div>

  <!-- 功能区 -->
  <div class="gridArea">
    <!-- 数据列表 -->
    <div class="cf btns">
      <div class="fr">
        <a href="#" class="ui-btn-bill ui-btn-hl btn-sm fl" id="export" style="margin-right: 20px;">导出</a>
        <a href="#" class="ui-btn-bill ui-btn-hl btn-sm fl" id="billDelete">删除</a>
      </div>
    </div>
    <div class="grid-wrap">
      <table id="grid">
      </table>
      <div id="page"></div>
    </div>
  </div>

</div>
<script type="text/javascript">
  //鼠标移开时隐藏展开的列表
  $('#toolBottom').on('mouseleave.menuEvent', '.ui-btn-menu', function (e) {
    $(this).removeClass('ui-btn-menu-cur');
  });
  $('#toolBottom').on('mouseover', '.ui-btn-menu', function (e) {
    $(this).addClass('ui-btn-menu-cur');
  });
</script>

<script type="text/javascript">
  var Pdata;
  var edit_row = 0;
  var edit_col = 0;
  var row_id = 0;
  var col_name = 0;



  $(document).ready(function () {
    // 获取当前日期
    var myDate = new Date;
    var year = myDate.getFullYear(); //获取当前年
    var mon = myDate.getMonth() + 1; //获取当前月
    var date = myDate.getDate(); //获取当前日
    console.log(year + '-' + mon + '-' + date)
    if (mon < 10) {
      mon = "0" + mon;
    }
    if (date < 10) {
      date = "0" + date;
    }
    $("#filter-billFromDate,#filter-fromDate").val(year + '-' + mon + '-01');
    $("#filter-billToDate,#filter-toDate").val(year + '-' + mon + '-' + date);


    // 跳转打开新标签页
    $(".ta").click(function () {
      var tabid = $(this).attr('tabid');
      var tabTxt = $(this).attr('tabTxt');
      var _href = $(this).attr('_href');
      parent.tab.addTabItem({
        tabid: tabid,
        text: tabTxt,
        url: _href
      })
    });

    var outhtml = '';
    var inhtml = ' ';


    $("#grid").jqGrid({
      url: '/sales/salesbilling/index.html?ajax=100',
      datatype: "json",//数据来源，本地数据（local，json,jsonp,xml等）
      height: '90%',//高度，表格高度。可为数值、百分比或'auto'
      colNames: ["操作", "单据日期", "单据编号", "客户", "金额", "税额", "价税合计", "收款状态", "开票日期", "开票金额", "发票号", "发票抬头"],
      colModel: [
        { name: 'id', index: 'id', width: 50, formatter: actions, align: "center" },
        { name: 'order_addtime', width: 100, label: "单据日期", align:'center' },
        { name: 'sn', index: '', width: 120, label: "单据编号" , align:'center'},
        { name: 'customer', index: '', width: 200, label: "客户", },
        { name: 'yh_price', index: '', width: 100, label: "金额", editable: false, align:'right' },
        { name: 'tax_e', index: '', width: 80, label: "税额", editable: false, align:'right' },
        { name: 'total_price', index: '', width: 100, label: "价税合计", editable: false, align:'right' },
        { name: 'payment_status', index: '', width: 100, label: "收款状态", editable: false, align:'center' },
        { name: 'addtime', index: '', width: 100, label: "开票日期", editable: false , align:'center'},
        { name: 'invoice_price', index: '', width: 100, label: "开票金额", editable: false , align:'right'},
        { name: 'invoice_no', index: '', width: 200, label: "发票号", editable: false, align:'center' },
        { name: 'invoice_title', index: '', width: 200, label: "发票抬头", editable: false },
      ],
      //   cellEdit: true,
      //   cellurl: '/',
      rowNum: 10,
      rowList: [10, 20, 30],
      sortname: 'id',
      sortorder: "desc",
      pagerpos: "left",//分页位置

      pgbuttons: true,//翻页按钮
      pagination: true,
      altRows: !0,
      gridview: !0,
      shrinkToFit: !1,
      cellLayout: 8,
      autowidth: !0,
      pager: "#page",
      multiselect: true,//自带多选
      viewrecords: !0,
      cmTemplate: {
        sortable: !1,
        title: !1
      },
      // 合计
      footerrow: true,
      gridComplete: function () {
        var yh_prices = parseFloat($("#grid").getCol('yh_price', false, 'sum')).toFixed(2);
        var tax_es = parseFloat($("#grid").getCol('tax_e', false, 'sum')).toFixed(2);
        var total_prices = parseFloat($("#grid").getCol('total_price', false, 'sum')).toFixed(2);
        var invoice_prices = parseFloat($("#grid").getCol('invoice_price', false, 'sum')).toFixed(2);
        $("#grid").footerData('set', { "order_addtime": '合计：', yh_price:yh_prices , tax_e:tax_es , total_price:total_prices , invoice_price:invoice_prices});
      },
      loadError: function (t, e, i) {
        parent.Public.tips({
          type: 1,
          content: "操作失败了哦，请检查您的网络链接！"
        })
      },
      beforeEditCell: function (rowid, cellname, value, iRow, iCol) {
        col_name = cellname;
        edit_row = iRow;
        edit_col = iCol;
        row_id = rowid;

      },

      beforeSaveCell: function (rowid, cellname, value, iRow, iCol) {
        edit_row = iRow;
        edit_col = iCol;
        row_id = rowid;
      },
    });


  });

  function actions(cellvalue, options, rowObject) {
		return '<div class="operating"><span class="ui-icon ui-icon-trash" onclick="del(' + rowObject.id + ')">删除</span></div>';
	}


</script>
{include file="admin@public/footer" /}